import Router from "./router";
import React, {useEffect} from 'react'
import { apiGetUserInfo } from "./api";
import { useDispatch } from 'react-redux'

const App = () => {

  const dispatch = useDispatch();

  useEffect(() => {
    getUserInfo()
  }, [])

  const getUserInfo = () => {
    apiGetUserInfo().then(res => {
      // 将用户信息存储到redux中
      dispatch({type: 'CHANGE_USER_INFO', data: res.data})
    })
  }

  return (
    <div className="public">
      <Router/>
    </div>
  );
};

export default App;
